/*
	@desc  定时器&喇叭
	@date 20140518
	@author LiWang112358
*/
#include <reg52.h>

#define MAX_BASE 60000
#define step 10
unsigned int soundbase = 0;

int init_timer()
{
    TMOD |= 0x01;
    TH0 = 0x00;
    TL0 = 0x00;
    EA = 1;
    ET0 = 1;
    TR0 = 1;
    P1 = 0;
}

void timer_callback(void) interrupt 1
{
    TH0 = 0xff & soundbase;
    TL0 = 0x00;
    P1 = ~P1;
}

int delay(int x)
{
	int i;
	for (i = 0; i < x; ++ i);
	return 0;
}

int main()
{
	init_timer();
	while(1){
		delay(5000);
		soundbase += 1;
		soundbase %= 0xff;
	}
	return 0;
}